<template>
  <el-card header="全局设置">
    <div class="layout">
      <div class="menu">
        <el-menu
          background-color="#fff"
          text-color="#000"
          active-text-color="#1890ff"
          :default-active="defaultActive"
          class="el-menu-vertical-demo"
          @select="select"
        >
          <el-menu-item :index="it.name" v-for="it in page">
            <span>{{ it.name }}</span>
          </el-menu-item>
        </el-menu>
      </div>
      <div class="content">
        <router-view />
      </div>
    </div>
  </el-card>
</template>

<script setup lang="ts">
import { ref, reactive, nextTick } from 'vue'
import { useRouter, useRoute } from 'vue-router'

const router = useRouter()
const route = useRoute()

defineOptions({
  name: 'globalSettings'
})

const page = [
  {
    name: '单位logo',
    route: 'GlobalSettingsLogo'
  },
  {
    name: '系统名称',
    route: 'GlobalSettingsSystemName'
  },
  {
    name: '版权/所有权',
    route: 'GlobalSettingsCopyright'
  },
  {
    name: '页面主题颜色',
    route: 'GlobalSettingsPageThemeColors'
  },
  {
    name: '系统状态',
    route: 'GlobalSettingsSystemStatus'
  },
  {
    name: '错误页面',
    route: 'GlobalSettingsErrorPage'
  }
]

const defaultActive = ref(page.find((i) => i.route === route.name).name)

const select = (e) => {
  router.push({
    name: page.find((i) => i.name === e).route
  })
}

</script>
<style lang="scss" scoped>
:deep(.el-card__body) {
  padding: 0;
}
.el-menu-vertical-demo :deep(.is-active) {
  background: #e6f7ff;
}

.el-menu-vertical-demo :deep(.el-menu-item):hover {
  background: #e6f7ff;
}

.layout {
  width: 100%;
  display: flex;
  padding-bottom: 20px;
  .menu {
    width: 208px;
  }
  .content {
    flex: 1;
    box-sizing: border-box;
    padding: 20px;
  }
}
</style>
